package com.example.springcloud.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.example.springcloud.domain.Route;
import io.swagger.annotations.*;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.example.springcloud.domain.Path;
import com.example.springcloud.service.IPathService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 途径点Controller
 * 
 * @author helian
 * @date 2025-03-01
 */
@RestController
@RequestMapping("/jiu-mount-huangshan/path")
@Api(tags = "途径点管理")
public class PathController extends BaseController
{
    @Autowired
    private IPathService pathService;

    /**
     * 查询途径点列表
     */
    @GetMapping("/list")
    @ApiOperation(value = "查询途径点列表")
    @ApiImplicitParams({@ApiImplicitParam(name = "path", value = "查询途径点列表", required = true, dataType = "Path")})
    @ApiResponses(@ApiResponse(code = 200, message = "查询景点信息列表成功", response = Path.class , responseContainer = "List"))
    public TableDataInfo list(Path path)
    {
        startPage();
        List<Path> list = pathService.selectPathList(path);
        return getDataTable(list);
    }

    /**
     * 导出途径点列表
     */
    @PreAuthorize("@ss.hasPermi('jiu-mount-huangshan:path:export')")
    @Log(title = "途径点", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Path path)
    {
        List<Path> list = pathService.selectPathList(path);
        ExcelUtil<Path> util = new ExcelUtil<Path>(Path.class);
        util.exportExcel(response, list, "途径点数据");
    }

    /**
     * 获取途径点详细信息
     */
    @PreAuthorize("@ss.hasPermi('jiu-mount-huangshan:path:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(pathService.selectPathById(id));
    }

    /**
     * 新增途径点
     */
    @PreAuthorize("@ss.hasPermi('jiu-mount-huangshan:path:add')")
    @Log(title = "途径点", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Path path)
    {
        return toAjax(pathService.insertPath(path));
    }

    /**
     * 修改途径点
     */
    @PreAuthorize("@ss.hasPermi('jiu-mount-huangshan:path:edit')")
    @Log(title = "途径点", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Path path)
    {
        return toAjax(pathService.updatePath(path));
    }

    /**
     * 删除途径点
     */
    @PreAuthorize("@ss.hasPermi('jiu-mount-huangshan:path:remove')")
    @Log(title = "途径点", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(pathService.deletePathByIds(ids));
    }
}
